package com.abm;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ListView;
import android.widget.TextView;

import com.abm.entity.ListaActividad;
import com.abm.xml.About;
import com.abm.xml.RssParserDom;

public class AboutActivity extends ListaActividad {

	private List<About> about;
	private ListView listView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		setContentView(R.layout.activity_about);

		RssParserDom saxparser = 
				new RssParserDom("http://feeds.feedburner.com/bernskiold");

		about = saxparser.parse();
		
		listView = (ListView) getListView();
		
		CustomAdapter_about_iconrow adapter = new CustomAdapter_about_iconrow(this, about);
		
		listView.setAdapter(adapter);
		
	}
	
	
	
	
	public class CustomAdapter_about_iconrow 
		extends BaseAdapter
		implements Filterable {

		private Context mContext;
		private List<About> about_list;
		
		
		public CustomAdapter_about_iconrow(Context context,
				List<About> aboutList) {
			mContext = context;
			this.about_list = aboutList;
		
		}
		
		public View getView(final int position, View v, ViewGroup parent) {
			View mView = v;
			if (mView == null) {
				LayoutInflater vi = (LayoutInflater) mContext
						.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				mView = vi.inflate(R.layout.custom_row_about, null);
			}
		
			TextView tv_title = (TextView) mView
					.findViewById(R.id.txtTitle);
			TextView tv_contents = (TextView) mView
					.findViewById(R.id.txtContents);
		
			
		
			if (about_list.get(position) != null) {
				tv_title.setTextColor(Color.BLACK);
				tv_title.setText(about_list.get(position).getTitulo());
		
				tv_contents.setTextColor(Color.BLACK);
				String desc = about_list.get(position).getDescripcion();
				tv_contents.setText(desc);	
			}
		
			return mView;
		}
	
		public int getCount() {
			return about_list.size();
		}

		public Object getItem(int position) {
			return about_list.get(position);
		}

		public long getItemId(int position) {
			return position;
		}
	
		@Override
		public Filter getFilter() {
			// TODO Auto-generated method stub
			return null;
		}
		
	
	
	}



}
